package com.rico.provider;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.client.RestTemplate;

@Service
public class RibbonProvider {
    @Autowired
    RestTemplate restTemplate;
    @RequestMapping(value = "/add", method = RequestMethod.GET)

    @HystrixCommand(fallbackMethod = "serviceFailure")
    public String add() {
        return restTemplate.getForEntity("http://alibaba-sentinel/add?a=10&b=20", String.class).getBody();
    }

    public String addFailure() {
        return "hello world service is not available !";
    }
}
